#include "PathTools.h"
namespace RE
{
	namespace IO
	{



Path& FilePath::GetPath()
{
	return m_path;
}
std::wstring& FilePath::GetFile()
{
	return m_file;
}
std::wstring FilePath::GetFileName()
{
	if(IsEmpty())
	{
		return std::wstring(L"Empty FilePath!");
	}
	return m_file;
}
std::wstring FilePath::GetExtension()
{
	if(IsEmpty())
	{
		return std::wstring(L"Empty FilePath!");
	}
	return m_file.substr(m_file.find_last_of(L"."));
}
bool FilePath::SetPath(Path & str)
{
	m_path = str;
}
bool FilePath::SetFileName(std::wstring & str)
{
	m_file = str;
}
bool FilePath::SetExtension(std::wstring & str)
{
	if(!IsEmpty())
	{
		m_file.erase(m_file.find_last_of(L"."));
		m_file.append(str);
		return true;
	}
	return false;
}


static const char* forbidden_symbols = "*:<>\"|?";
bool Path::ValidatePath(const std::wstring & str)
{
	for(int i = 0; i < str.length(); ++i)
	{
		for(int u = 0; u < strlen(forbidden_symbols); ++u)
		{
			if(str[i] == forbidden_symbols[u])
			{
				return false;
			}
		}
	}
	return true;
}

bool Path::ValidatePath(const std::string & str)
{
	for(int i = 0; i < str.length(); ++i)
	{
		for(int u = 0; u < strlen(forbidden_symbols); ++u)
		{
			if(str[i] == forbidden_symbols[u])
			{
				return false;
			}
		}
	}
	return true;
}
Path::Path(const char * const dir)
{
	std::string str = dir;
	if(ValidatePath(str))
	{
		m_path.append(str.begin(), str.end());
	}
}
Path::Path(const TCHAR* const dir)
{
	std::wstring str = dir;
	if(ValidatePath(str))
	{
		m_path = str;
	}
}
Path::Path(const std::wstring& const dir)
{
	if(ValidatePath(dir))
	{
		m_path = dir;
	}
}
Path::Path(const std::string& dir)
{
	if(ValidatePath(dir))
	{
		m_path.append(dir.begin(), dir.end());
	}
}
const std::wstring&	Path::GetPath()
{
	return m_path;
}
std::wstring Path::GetPathCopy()
{
	return m_path;
}

std::wstring Path::GetAbsolutePath()
{
	if(!g_OSFramework || IsEmpty())
	{
		return std::wstring(L"Invalid");
	}
	g_OSFramework->GetApplicationDir();
}
bool Path::IsEmpty()
{
	if(m_path.length() == 0)
	{
		return true;
	}
	return false;
}

	}
}